package com.ruoyi.apartmentattribute.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.apartmentattribute.domain.Apartmentattribute;
import com.ruoyi.apartmentattribute.service.IApartmentattributeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公寓属性Controller
 * 
 * @author ruoyi
 * @date 2024-10-14
 */
@RestController
@RequestMapping("/apartmentattribute/apartmentattribute")
public class ApartmentattributeController extends BaseController
{
    @Autowired
    private IApartmentattributeService apartmentattributeService;

    /**
     * 查询公寓属性列表
     */
    @PreAuthorize("@ss.hasPermi('apartmentattribute:apartmentattribute:list')")
    @GetMapping("/list")
    public TableDataInfo list(Apartmentattribute apartmentattribute)
    {
        startPage();
        List<Apartmentattribute> list = apartmentattributeService.selectApartmentattributeList(apartmentattribute);
        return getDataTable(list);
    }

    /**
     * 导出公寓属性列表
     */
    @PreAuthorize("@ss.hasPermi('apartmentattribute:apartmentattribute:export')")
    @Log(title = "公寓属性", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Apartmentattribute apartmentattribute)
    {
        List<Apartmentattribute> list = apartmentattributeService.selectApartmentattributeList(apartmentattribute);
        ExcelUtil<Apartmentattribute> util = new ExcelUtil<Apartmentattribute>(Apartmentattribute.class);
        util.exportExcel(response, list, "公寓属性数据");
    }

    /**
     * 获取公寓属性详细信息
     */
    @PreAuthorize("@ss.hasPermi('apartmentattribute:apartmentattribute:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(apartmentattributeService.selectApartmentattributeById(id));
    }

    /**
     * 新增公寓属性
     */
    @PreAuthorize("@ss.hasPermi('apartmentattribute:apartmentattribute:add')")
    @Log(title = "公寓属性", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Apartmentattribute apartmentattribute)
    {
        return toAjax(apartmentattributeService.insertApartmentattribute(apartmentattribute));
    }

    /**
     * 修改公寓属性
     */
    @PreAuthorize("@ss.hasPermi('apartmentattribute:apartmentattribute:edit')")
    @Log(title = "公寓属性", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Apartmentattribute apartmentattribute)
    {
        return toAjax(apartmentattributeService.updateApartmentattribute(apartmentattribute));
    }

    /**
     * 删除公寓属性
     */
    @PreAuthorize("@ss.hasPermi('apartmentattribute:apartmentattribute:remove')")
    @Log(title = "公寓属性", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(apartmentattributeService.deleteApartmentattributeByIds(ids));
    }
}
